package com.cb.domain.dao.system.impl;

import java.util.List;
import java.util.ArrayList;
import org.springframework.stereotype.Repository;
import com.cb.core.dao.hibernate.GenericDAOHibernate;
import com.cb.domain.model.system.SystemUser;
import com.cb.domain.model.user.UserAccount;
import com.cb.domain.dao.system.SystemUserDAO;
import com.cb.core.webapp.paging.PagingBean;

@Repository
public class SystemUserDAOImpl extends GenericDAOHibernate<SystemUser, Long> implements SystemUserDAO {
	public SystemUserDAOImpl() {
		super(SystemUser.class);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public List<SystemUser> getByVo(SystemUser vo, PagingBean pb) {
		List<Object>paramList=new ArrayList<Object>();
		String hql="from SystemUser vo where 1=1";
		
		/**TODO 添加自己的需要加入的查询条件
		if(StringUtils.isNotEmpty(vo.getUsername())){
			hql+=" and vo.username like ?";
			paramList.add("%"+vo.getUsername()+"%");
		}**/
		
		List <SystemUser>list=this.find(hql, paramList.toArray(), pb);
		return list;
	}

	@Override
	public SystemUser findByUserName(String userName) {
			String queryString = "from SystemUser where username=?";
			return (SystemUser) findUnique(queryString, new Object[] { userName });
	}
}

